package com.dxy.dxyuser.service.impl;

import com.dxy.dxyuser.service.TokenManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class TokenManagerImpl implements TokenManager {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public boolean isExistToken(String userId) {
        String token;
        try {
            token = stringRedisTemplate.opsForValue().get(userId);
        } catch (Exception e) {
            token = null;
        }
        if (token == null){
            return false;
        }
        return true;
    }
}
